FROM ubuntu:xenial
RUN sed -i 's/http:\/\/archive\.ubuntu\.com\/ubuntu\//http:\/\/mirrors\.163\.com\/ubuntu\//g' /etc/apt/sources.list
RUN echo 'deb [trusted=yes] http://200.200.200.1:8080/ubuntu1604 cloudstack4.11/' >> /etc/apt/sources.list
RUN apt update
RUN apt-get install ntp cloudstack-management -y
RUN ln /etc/init.d/tomcat7 /etc/init.d/tomcat \
    && mkdir -p /export/primary \
    && mkdir /export/secondary

RUN apt install openssh-server python-psutil uuid-runtime -y
RUN chmod -R 777 /root
ENV MYSQL_HOST MYSQL_PORT MYSQL_USER MYSQL_PASSWORD SYSTEMVM_URL='http://200.200.200.4/systemvm64template-4.10-vmware.ova' NFS='200.200.200.1:/export/cloudstack/s'
ADD run.py run.sh register_tmpl.sh /

HEALTHCHECK --interval=3m --timeout=100s \
  CMD curl -f http://localhost:8080/client || exit 1

ENTRYPOINT ["bash", "run.sh"]